// 判断菜单是否有权限
export function getMenuAuth(
  vipInfo: any,
  currentLevel: number,
  isLogin: boolean
) {
  if (!isLogin) {
    return currentLevel === 0;
  }
  // 过期了
  if (new Date(vipInfo?.expire_time).getTime() < Date.now()) {
    return currentLevel === 0;
  }
  return vipInfo?.level >= currentLevel;
}

export function isVip(vipInfo: any) {
  return new Date(vipInfo?.expire_time).getTime() < Date.now()
    ? false
    : vipInfo?.level > 0;
}

// 生成随机数
export function randomId() {
  // const max = BigInt('9223372036854775807'); // 2^63 - 1
  const max = BigInt("100000000");
  return Math.floor(Math.random() * Number(max));
}
